// 定义记分牌
class ScopePanel {
    scope = 0;
    level = 1;
    // 最大等级
    maxLevel:number;
    // 多少分数升一级
    upScope:number;

    scopeEle:HTMLElement;
    levelEle:HTMLElement;
    constructor(maxLevel:number=10,upScope:number=10) {
        this.scopeEle = document.getElementById("scope")!
        this.levelEle = document.getElementById("level")!
        this.maxLevel = maxLevel
        this.upScope = upScope;
    }

    // 设置一个加分的方法
    addScope() {
        this.scopeEle.innerHTML = ++this.scope + ""
        if (this.scope % this.upScope == 0) {
            this.levelUp()
        }
    }

    // 等级提升
    levelUp(){
        // 等级的上限
        if(this.level < this.maxLevel){
            this.levelEle.innerHTML = ++this.level + ""
        }
    }
    
}

export default ScopePanel